package com.gcxy.controller;


import com.gcxy.conf.result.R;
import com.gcxy.dto.RanchAddDTO;
import com.gcxy.dto.RanchPageDTO;
import com.gcxy.dto.RanchUpdateDTO;
import com.gcxy.service.IRanchService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 牧场管理 前端控制器
 * </p>
 *
 * @author author
 * @since 2024-12-25
 */
@RestController
@RequestMapping("/ranch")
@Api(value = "ranchController", tags = "牧场管理")
public class RanchController {
    @Autowired
    private IRanchService ranchService;

    @ApiOperation("新增牧场")
    @PostMapping("/addRanch")
    public R addRanch(@Validated @RequestBody RanchAddDTO ranchAddDTO) {
        return ranchService.addRanch(ranchAddDTO);
    }


    @ApiOperation("根据id停用启用")
    @PutMapping("/changeRanchStatus/{id}")
    public R changeRanchStatus(@PathVariable String id) {
        return ranchService.changeRanchStatus(id);
    }


    @ApiOperation("根据牧场id获取牧场信息")
    @GetMapping("/getRanchById/{id}")
    public R getRanchById(@PathVariable String id) {
        return ranchService.getRanchById(id);
    }


    @ApiOperation("修改牧场")
    @PutMapping("/updateRanch")
    public R updateRanch(@Validated @RequestBody RanchUpdateDTO ranchUpdateDTO) {
        return ranchService.updateRanch(ranchUpdateDTO);
    }


    @ApiOperation("删除牧场")
    @DeleteMapping("/deleteRanch/{id}")
    public R deleteRanch(@PathVariable String id) {
        return ranchService.deleteRanch(id);
    }


    @ApiOperation("获取牧场列表")
    @PostMapping("/getRanchList")
    public R getRanchList(@RequestBody RanchPageDTO ranchPageDTO) {
        return ranchService.getRanchList(ranchPageDTO);
    }
}
